import { test, expect } from '@playwright/test';

test.describe('Health Checks', () => {
  test('app should load successfully', async ({ page }) => {
    await page.goto('/');

    // Should see the app brand/logo
    await expect(page.locator('a.navbar-brand')).toBeVisible({ timeout: 10000 });

    // Should see navigation
    await expect(page.locator('nav.navbar')).toBeVisible();
  });

  test('API should be accessible', async ({ request }) => {
    const response = await request.get('https://api.realworld.show/api/tags');
    expect(response.ok()).toBeTruthy();
  });

  test('can navigate to login page', async ({ page }) => {
    await page.goto('/login');

    // Should see login form
    await expect(page.locator('h1')).toContainText('Sign in', { timeout: 10000 });
    await expect(page.locator('input[formControlName="email"]')).toBeVisible();
  });

  test('can navigate to register page', async ({ page }) => {
    await page.goto('/register');

    // Should see register form
    await expect(page.locator('h1')).toContainText('Sign up', { timeout: 10000 });
    await expect(page.locator('input[formControlName="username"]')).toBeVisible();
  });
});
